package cn.bonoon.kernel.web.components;

import cn.bonoon.kernel.descriptors.UIPropertyAccessor;
import cn.bonoon.kernel.web.annotations.components.AsNumberSpinner;
import cn.bonoon.kernel.web.html.UIPropertyBuilder;
import cn.bonoon.kernel.web.html.form.ComponentPropertyParser;

public class NumberSpinnerComponent extends UIComponent{
	private final AsNumberSpinner com;
	public NumberSpinnerComponent(ComponentPropertyParser property, UIPropertyAccessor accessor, AsNumberSpinner asNumberSpinner) {
		super("bupnuminput", property, accessor);
		this.com = asNumberSpinner;
	}
	@Override
	protected void initComponentAttribute(StringBuilder script, UIPropertyBuilder builder) {
		if (!Double.isNaN(com.max())){
			script.append(",max:").append(com.max());
		}
		if (!Double.isNaN(com.min())){
			script.append(",min:").append(com.min());
		}
		if (com.increment() > 0){
			script.append(",increment:").append(com.increment());
		}
	}
}
